package com.servlet;

import com.dao.StudentDao;
import com.vo.StudentVo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

public class ProcServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ProcServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String stuNo = request.getParameter("stuNo");
		StudentDao sd = new StudentDao();
		String name = sd.getNameProc1(stuNo);



        String sql = "STUDENTNAME like '%"+name+"%'";
		System.out.print(name);
		ArrayList<StudentVo> list = sd.selectStudent(sql);
		request.setAttribute("list", list);
		request.getRequestDispatcher("stu/studentList.jsp").forward(request, response);
	
	}

	
	public void init() throws ServletException {
		// Put your code here
	}

}
